#coding=utf-8
import subprocess, time
#download_tool = '/Users/young_jay/py/article/get1article.py'
download_tool = '/home/jay/xiaojaylib/article/get1article.py'
command = 'python %s %s'

article_list = 'article_list.txt'
log = 'f.txt'
f = open('f.txt', 'w')

def print_red(s):print '\033[0;31;48m%s\033[0m'%s

for title in file( article_list):
    title = title.strip()
    if not title:continue
    
    print_red(title)

    #p = subprocess.Popen(command%(download_tool, title), shell=True, stdout=open('o.txt', 'a'), stderr=open('e.txt', 'a'))
    r = subprocess.call( command%(download_tool, title), shell=True, )#stdout=open('o.txt', 'a'), stderr=open('e.txt', 'a'))
    print r
    if r!=0:
        f.write('%s\n'%title)
        f.flush()
    time.sleep(2)
